package com.fristvue.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.fristvue.po.GoodsType;
import com.fristvue.po.Util.Page;
import com.fristvue.service.GoodsTypeService;

@RestController
public class GoodsTypeController {
	
	@Autowired
	private GoodsTypeService goodsTypeService;
	
	@RequestMapping("TypeAll/{page}/{size}")
	public Page<GoodsType> selectTypeAll(@PathVariable("page") Integer page,
    		@PathVariable("size") Integer size, @RequestBody GoodsType goodsType){
		Integer num = page * size;
		return this.goodsTypeService.selectGoodsType(num, size, goodsType);
	}
	
	@PutMapping("addType")
	public boolean addType(@RequestBody GoodsType goodsType) {
		return this.goodsTypeService.insert(goodsType);
	}
	
	@DeleteMapping("deleteType")
	public boolean deleteType(Integer id) {
		return this.goodsTypeService.deleteType(id);
	}
	
	@RequestMapping("findByIdType")
	public GoodsType findByIdType(Integer id) {
		return this.goodsTypeService.FindByIdType(id);
	}
	
	@PutMapping("updateType")
	public boolean updateType(@RequestBody GoodsType goodsType) {
		return this.goodsTypeService.updateById(goodsType);
	}
}
